#pragma once
#include "MemoryPhysical.h"
#include "PageTableTool.h"
typedef enum _READWRITEMETHOD {
	READWRITEATTACH,
	READWRITEINTEL,
	READWRITECR3,
	READWRITEMDL,
}READWRITEMETHOD;



//typedef struct _MEMORY_BASIC_INFORMATION {
//	PVOID BaseAddress;
//	PVOID AllocationBase;
//	ULONG64 AllocationProtect;
//	SIZE_T RegionSize;
//	ULONG64 State;
//	ULONG64 Protect;
//	ULONG64 Type;
//} MEMORY_BASIC_INFORMATION, * PMEMORY_BASIC_INFORMATION;
//
//
//typedef struct _MEMORY_BASIC_INFORMATION32 {
//	ULONG BaseAddress;
//	ULONG AllocationBase;
//	ULONG AllocationProtect;
//	ULONG RegionSize;
//	ULONG State;
//	ULONG Protect;
//	ULONG Type;
//} MEMORY_BASIC_INFORMATION32, * PMEMORY_BASIC_INFORMATION32;

EXTERN_C
NTSTATUS
NTAPI
NtProtectVirtualMemory(
	__in HANDLE ProcessHandle,
	__inout PVOID* BaseAddress,
	__inout PSIZE_T RegionSize,
	__in ULONG NewProtect,
	__out PULONG OldProtect
);



NTSTATUS
NtQueryVirtualMemory(
	__in HANDLE ProcessHandle,
	__in PVOID BaseAddress,
	__in MEMORY_INFORMATION_CLASS MemoryInformationClass,
	__out_bcount(MemoryInformationLength) PVOID MemoryInformation,
	__in SIZE_T MemoryInformationLength,
	__out_opt PSIZE_T ReturnLength
);





//ͨ����������ڴ�,x������Ҫ��֤��λ
EXTERN_C PVOID SearchPatter(PCH base, DWORD length, PCH pattern, PCH mask);

//ģ������,*����ģ����ֵ
EXTERN_C PVOID SearchPatterFuzzy(PCH base, DWORD length, PCH pattern, ULONG_PTR size);




ULONG64 wpoff();

VOID wpOn(ULONG64 old);


NTSTATUS ReadMemoryDirect(PEPROCESS process, PVOID targetAddress, PVOID buffer, SIZE_T size);
//MmCopyVirtualMmeory
NTSTATUS ReadMemoryByIntelFunc(PEPROCESS process, PVOID targetAddress, PVOID buffer, SIZE_T size);
//MDL
NTSTATUS ReadMemoryByMdl(PEPROCESS process, PVOID targetAddress, PVOID buffer, SIZE_T size);
//SwitchCr3
NTSTATUS ReadMemoryByCr3(PEPROCESS process, PVOID targetAddress, PVOID buffer, SIZE_T size);
EXTERN_C
NTSTATUS ReadMmeory(HANDLE pid, PVOID targetAddress, PVOID buffer, SIZE_T size, READWRITEMETHOD method);

EXTERN_C
NTSTATUS WriteMemory(HANDLE pid, PVOID targetAddress, PVOID buffer, SIZE_T size);

EXTERN_C
NTSTATUS QueryMemory(HANDLE pid, PVOID targetAddress, PMEMORY_BASIC_INFORMATION memoryBasicInfo);

